<?php
/**
 * RAI 时间戳验证类
 * 
 * 该类目前仅供测试用
 *
 * @version $Id: RaiTimeValidator.php 312 2008-04-23 16:29:38Z iwind $
 * @package net.4kiki.rai.server.validator
 * @since 0.0.3
 */
class RaiTimeValidator extends AbstractRaiValidator {
	private $maxAge = 0;
	private $parameterName;
	
	public function __construct($maxAge, $parameterName = "time") {
		$this->maxAge = intval($maxAge);
		$this->parameterName = $parameterName;
	}
	
	public function validate() {
		$arguments = $this->getRequest()->getArguments();
		if (!isset($arguments[0][$this->parameterName])) {
			$this->setFault(new RaiFault(5010, "lack of '" . $this->parameterName . "'"));
			return false;
		}
		if ($arguments[0][$this->parameterName] < time()) {
			$this->setFault(new RaiFault(5011, "request is expired"));
			return false;
		}
		return true;
	}
}

?>